<!DOCTYPE html>
<html lang="en">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="css/style.css" rel="stylesheet">
</head>

<body>
    <script>
        let arr = [4, 1, 2, 7]
        let res = 0;

        for (let i = 0; i < arr.length; i++) {
            for (let j = i + 1; j < arr.length; j++) {
                res = Math.max((j - i) * (Math.min(arr[i], arr[j])), res)
            }
        }
        console.log(res)
    </script>
</body>

</html>